package cn.njxzc.examples;

interface Access {
	void put(char ch);

	char get();
}

class Stack implements Access {
	private char array[] = new char[80];
	private int top = 0;

	public void put(char ch) {
		array[top++] = ch;
	}

	public char get() {
		return array[--top];
	}
}

class Queue implements Access {
	private char array[] = new char[80];
	private int frontin = 0, readout = 0;

	public void put(char ch) {
		array[readout++] = ch;
	}

	public char get() {
		return array[frontin++];
	}
}

class Exam3_23 {
	public static void main(String[] args) {
		Stack s = new Stack();
		s.put('1');
		s.put('2');
		s.put('3');
		s.put('4');
		System.out.println("Stack:");
		System.out.println(s.get());
		System.out.println(s.get());
		System.out.println(s.get());
		System.out.println(s.get());
		Queue q = new Queue();
		q.put('5');
		q.put('6');
		q.put('7');
		q.put('8');
		System.out.println("Queue:");
		System.out.println(q.get());
		System.out.println(q.get());
		System.out.println(q.get());
		System.out.println(q.get());

	}

}